package com.gis.premd;

import com.gis.beans;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author leon
 * @ClassName PreMapper.java
 * @createTime 2021年09月26日 12:06:00
 */
public class PreMapper extends Mapper<LongWritable, Text, Text, beans> {

    private Text outK = new Text();
    private beans outV = new beans();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String lines = value.toString();

        String[] element = lines.split(",");

        String mmsi = element[0];
        Long unixTime = new Long(element[1]);
        Double speed = new Double(element[2]);
        Double lon_d = new Double(element[3]);
        Double lat_d = new Double(element[4]);

        outK.set(mmsi);

        outV.setMmsi(mmsi);
        outV.setUnixTime(unixTime);
        outV.setSpeed(speed);
        outV.setLat_d(lat_d);
        outV.setLon_d(lon_d);

        context.write(outK, outV);

    }
}
